package com.example;

import de.greenrobot.daogenerator.DaoGenerator;
import de.greenrobot.daogenerator.Entity;
import de.greenrobot.daogenerator.Property;
import de.greenrobot.daogenerator.Schema;

public class ExampleDaoGenerator {
    public static void main(String[] args) throws Exception {
        Schema schema = new Schema(1, "oa.database.bean");
        schema.setDefaultJavaPackageDao("oa.database.dao");

//         schema.enableActiveEntitiesByDefault();
         schema.enableKeepSectionsByDefault();

        addNote(schema);

        new DaoGenerator().generateAll(schema, "D:/fuying/work/OA_manage/app/src/main/java-gen");
    }

    /**
     * @param schema
     */
    private static void addNote(Schema schema) {
        Entity employee = schema.addEntity("Employee");

        employee.addLongProperty("uid").primaryKey();
        employee.addLongProperty("vid");
        employee.addStringProperty("userName").notNull();
        employee.addStringProperty("hearImage");
        employee.addBooleanProperty("online");
        employee.addStringProperty("gangWei");
        employee.addBooleanProperty("isUsual");

        Entity department = schema.addEntity("Department");
        department.addLongProperty("pid").primaryKey();
        department.addStringProperty("departName").notNull();
        department.addLongProperty("mid").notNull();
        department.addStringProperty("managerName");

        Entity friends = schema.addEntity("Friends");
        friends.addLongProperty("uid");
        friends.addLongProperty("fid");

        Property property = employee.addLongProperty("pid").getProperty();
        employee.addToOne(department,property);
        department.addToMany(employee,property);

//        Property property2 = employee.addLongProperty("fid").getProperty();
//        friends.addToOne(employee,property).setName("Employee");
//        employee.addToMany(friends,property);

    }
}
